package loadBalancer;

import register.Registry;
import spi.SpiLoader;

/**
 * 负载均衡器工厂
 */
public class LoadBalancerFactory {
    private static final LoadBalance DEFAULT_LOAD_BALANCER = new ConsistentHashBalancer();
    static {
        SpiLoader.load(LoadBalance.class);
    }

    /**
     * 根据负载均衡对应的种类key，获取对应的负载均衡器对象（默认采取spi机制）
     * @param localBalancerKey
     * @return
     */
    public static LoadBalance getInstance(String localBalancerKey){
        return SpiLoader.getInstance(LoadBalance.class,localBalancerKey);
    }
}
